package com.ting.mybatis.session;

import com.ting.mybatis.config.MyConfiguration;
import com.ting.mybatis.executor.MyExecutor;

public class MySqlSessionFactory {

    private MyConfiguration myConfiguration;

    public MySqlSessionFactory(MyConfiguration myConfiguration) {
        this.myConfiguration = myConfiguration;
    }


    /**
     * 打开MySqlSession: 意味着要打开跟数据库的连接
     * */
    public MySqlSession openSession(){
         //打开数据源
        //创建执行器，进行增删改查，把配置文件信息传进去，因为配置文件信息里有数据源的连接信息
        MyExecutor myExecutor=new MyExecutor(myConfiguration);

        return new MySqlSession(myConfiguration,myExecutor);

    }
}
